FROM python:3.12.0

# 设置构建参数
ARG work_home=/room
ARG pip_url=https://mirrors.aliyun.com/pypi/simple
ARG pip_host=mirrors.aliyun.com
# 定义一个变量，其值为项目在docker容器中的工作目录

# 设置python环境变量
ENV PYTHONUNBUFFERED 1

# 容器默认的时间是UTC时间，此处设置为上海时间
RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime


# 在容器中创建room文件夹
RUN mkdir -p ${work_home}

# 将容器中的room文件夹设置为工作目录
WORKDIR ${work_home}

# 将当前目录内容复制到容器的room目录，因为build中指定的context环境目录为project这一层，所以当前目录即项目目录
COPY . ${work_home}

# 复制 requirements.txt 文件到容器中
COPY requirements.txt ${work_home}/requirements.txt
RUN pip install --upgrade setuptools -i ${pip_url} --trusted-host ${pip_host}

# 更新 pip 并安装依赖
RUN pip install pip -U -i ${pip_url} --trusted-host ${pip_host}
RUN pip install cryptography -i ${pip_url} --trusted-host ${pip_host}
RUN pip install -r requirements.txt -i ${pip_url} --trusted-host ${pip_host}



RUN chmod 777 /room/logs  && chown -R www-data:www-data /room/logs  # 调整日志文件权限
RUN chmod 777 /room/docker_media/files/
RUN chmod 777 /room/docker_media/picture/

COPY development/dev/app/favicon.ico ${work_home}/docker_media/files/
COPY development/dev/app/yuanhui.png ${work_home}/docker_media/files/
# startapp.sh 文件拷贝到容器的根目录下
COPY development/dev/app/startapp.sh /startapp.sh
# 将deployment下的wait-for-it.sh文件拷贝到容器的根目录下
COPY development/dev/app/wait-for-it.sh /wait-for-it.sh


#修改权限
RUN chmod +x /wait-for-it.sh /startapp.sh

